﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using ChineseSchool.Models.Hethong;

namespace ChineseSchool.BLL
{
    public class B_Album
    {
        private PetaPoco.Database db;
        public B_Album()
        {
            db = new PetaPoco.Database("ConnectionString");
        }
        
        public List<M_Album> GetAlls()
        {
            var Album = db.Fetch<M_Album>(@";EXEC Album_Get_List");
            return Album;
        }

        public M_Album GetByPK(int AlbumID)
        {
            var loadAlbum = db.SingleOrDefault<M_Album>("SELECT * FROM Album m WHERE m.AlbumID = " + AlbumID + ";");
            db.CloseSharedConnection();
            return loadAlbum;
        }        

        public List<M_Album> GetBy_MenuID(int MenuID)
        {
            var Album = db.Fetch<M_Album>(@";EXEC Album_GetByMenuId @@MenuId = @0", MenuID);
            return Album;
        }        

        public List<M_Album> GetTop6Album()
        {
            var strSql = @"SELECT TOP 8 * FROM Album
                            ORDER BY CreateDate DESC";
            var lstTopUser = db.Fetch<M_Album>(strSql);
            return lstTopUser;
        }
    }
}